"""
Common.cpp extension. Unstable functions.
"""

import mjin2

def strToBool(s):
    return s.lower() == "true"

def readVec3(node):
    vec = mjin2.Vec3()
    for a in node.attrs:
        if (a.name == "x"):
            vec.x = float(a.value)
        elif (a.name == "y"):
            vec.y = float(a.value)
        elif (a.name == "z"):
            vec.z = float(a.value)
    return vec

def readVec4(node):
    vec = mjin2.Vec4()
    for a in node.attrs:
        if (a.name == "x"):
            vec.x = float(a.value)
        elif (a.name == "y"):
            vec.y = float(a.value)
        elif (a.name == "z"):
            vec.z = float(a.value)
        elif (a.name == "w"):
            vec.w = float(a.value)
    return vec

